package org.example.demo;

import java.util.*;

public class Demo04 {
    public static void ship(){
        Map<String, String> map = new HashMap<>();
        map.put("101","南昌舰");
        map.put("102","拉萨舰");
        map.put("103","鞍山舰");
        map.put("104","无锡舰");
        map.put("105","大连舰");
        map.put("106","延安舰");
        map.put("107","遵义舰");
        map.put("108","咸阳舰");

//        Set<String> keys = map.keySet();
//        for (String s : keys) {
//            System.out.println(s+"==="+map.get(s));
//        }
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
//        for (Map.Entry<String, String> entry : entrySet) {
//            System.out.print(entry.getKey());
//            System.out.println(entry.getValue());
//        }
        Iterator<Map.Entry<String, String>> iterator = entrySet.iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> next = iterator.next();
            System.out.print(next.getKey());
            System.out.println(next.getValue());
        }


    }

    public static void main(String[] args) {
        ship();
    }
}
